/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.scuecsz.utils;

/**
 *for mysql
 * @author Administrator
 */
public class StringUtil {
    public  final static String DIPLOMA="diploma";
    public  final static String PHOTO="photo";
    public  final static String SET="set";
    public final static String GET="get";
    public final static String LIMIT = " LIMIT ";
    public final static String EQUAL="=";
    public final static String COMMA = ",";
    public final static String DOT = ".";
    public final static String NULLSTRING="";
    public final static String SPACE=" ";
    public final static String CN_YEAR="年";
    public final static String CN_MONTH="月";
    public final static String CN_DAY="日";
//    public final static String CN_HOUR="点";
//    public final static String CN_MIN="分";
//    public final static String CN_SEC="秒";
    public final static String DATE_SEPARATOR="-";
//    public final static String TIME_SEPARATOR=":";

    public  static String getString(String dataString){
        return null==dataString?NULLSTRING:dataString;
    }

    public static String formatDate(String dataString){
        dataString=getString(dataString);
        return dataString.replaceFirst(DATE_SEPARATOR,CN_YEAR).replaceFirst(DATE_SEPARATOR, CN_MONTH).concat(CN_DAY);
    }

    public static String formatMySqlDate(String myDataString){
        myDataString=getString(myDataString);
        return myDataString.replaceFirst(CN_YEAR,DATE_SEPARATOR).replaceFirst(CN_MONTH, DATE_SEPARATOR).replaceFirst(CN_DAY, NULLSTRING);
    }

    public static String formatDateTime(String dataString){
        dataString=getString(dataString);
        if(!NULLSTRING.equals(dataString)){
            String[] temp=dataString.substring(0, 19).split(SPACE);
            dataString= formatDate(temp[0]).concat(SPACE).concat(temp[1]);
        }
        return dataString;
    }
}
